#ifndef UIEDIT_H
#define UIEDIT_H

#include "UIContainer.h"
#include "UILabel.h"

class UIEdit : public UILabel
{
  public:
    UIEdit(UIContainer *parent);
    ~UIEdit();

    // 类型
    std::string getUIType() override;

    // 内容为空时的占位文字
    DEFINE_PROPERTY(std::string, PlaceholderText, "");

    // 最大输入长度
    DEFINE_PROPERTY(int, MaxLength, 0);
    DEFINE_PROPERTY(bool, IsMultiLine, false);

    // 选中文本颜色
    DEFINE_PROPERTY(DuiColor, SelectionTextColor, DuiColor{255, 255, 255, 255});

    // 选中文本背景色
    DEFINE_PROPERTY(DuiColor, SelectionBackgroundColor, DuiColor{0, 0, 255, 100});

  protected:
    bool m_bWCharDone = true;
    wchar_t m_WCharBuff[2];

  public:
    // 纯虚函数实现
    void onDrawContent(DuiWinManager *mgr, DuiRect &rect_in, DuiRect &rect_out) override;
    void onMouseDown(int x, int y) override;
    void onMouseUp(int x, int y) override;
    void onMouseMove(int x, int y) override;
    void onMouseLeave() override;
    void onMouseEnter() override;
    void onMouseWheel(int delta, int x, int y) override;
    void onKeyDown(int key) override;
    void onKeyUp(int key) override;
    void onKeyChar(int key) override;
    void onImeChar(int key) override;
    void onCommand(int command, void *param) override;
};

#endif
